package com.xquant.common.engine.xPP.response;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.ArrayList;
import java.util.List;

@JsonInclude(JsonInclude.Include.NON_NULL)
public class CalcMarket {
    private Contract contract;
    private List<LegContract> legContract;

    public Contract getContract() {
        return contract;
    }

    public void setContract(Contract contract) {
        this.contract = contract;
    }

    public List<LegContract> getLegContract() {
        return legContract;
    }

    public void setLegContract(List<LegContract> legContract) {
        this.legContract = legContract;
    }

    public void merge(CalcMarket calcMarket){
        try {
            if (calcMarket == null) {
                return;
            }
            if (this.contract == null) {
                this.contract = new Contract();
            }
            this.contract.merge(calcMarket.getContract());

            if (calcMarket.getLegContract() != null) {
                if (this.legContract == null) {
                    this.legContract = new ArrayList<>();
                }
                this.legContract.addAll(calcMarket.getLegContract());
            }
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
